cap = 5# 背包能装6重量的物品
weight = [1, 2, 3, 4, 5] # 每个物品的重量
value = [50, 120, 150, 210, 240] # 每个物品的价值，上下对应
def find(n,weight):
    if n in weight:
        return weight.index(n)
    return None
def zhuang(cap,weight,value):
    if cap>=sum(weight):
        return sum(value)
    if cap<min(weight):
        return 0
    dp=[0]*(cap+1)
    dp[0]=0
    for i in range(len(weight)):
        for j in range(cap, weight[i] - 1, -1):
            dp[j] = max(dp[j], dp[j - weight[i]] + value[i])
    return dp[cap]
money=zhuang(cap,weight,value)
print(money)